<template>
  <div style="background-color: #FFFFFF; padding: 20px;">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">

      <el-form-item label="工具名称" prop="title">
        <el-input v-model="ruleForm.title"></el-input>
      </el-form-item>

      <el-form-item label="URL" prop="URL">
        <el-input v-model="ruleForm.URL"></el-input>
      </el-form-item>

      <el-form-item label="备注" prop="remark">
        <el-input v-model="ruleForm.remark"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm()">保存</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>
<script>
  export default {
    name: 'AddOftenMyTool',
    data() {
      return {

        optionsCommon: [],  // 存储CommonChoices实际数据的列表

        EditUrl: this.$http.OftenMyToolURL,  // get编辑的URL
        EditIdStr: 'often_my_tool_id',  // 模块id字符串
        pushObjName: 'OftenMyTool',  // 成功后跳转的路由

        ruleForm: {
          title: '',//工具名称
          URL: '',//URL
          remark: '', //备注
        },  //
        rules: {
          title: [
            {required: true, message: '请输入环境名称', trigger: 'blur'},
            {min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur'}
          ],
          URL: [
            {required: true, message: '请输入请求协议', trigger: 'blur'},
            {min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur'}
          ],
          remark: [
            {required: true, message: '请输入IP地址', trigger: 'change'},
            {min: 1, max: 1000, message: '长度在 1 到 1000 个字符', trigger: 'blur'}
          ],
        }
      };
    },
    created() {
      this.getEditData();   // get回将要编辑的数据
    },
    methods: {
      submitForm() {
        this.$myTool.submitForm(this)
      },

      // get回将要编辑的数据
      getEditData() {
        this.$myTool.getEditData(this)
      },

      //
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    },
    computed: {
      getChoices() {
        return this.$store.state.choicesInfo
      }
    },
  }
</script>
